// 引入
import Request from '@/libs/request'
import qs from 'qs'
import axios from 'axios'


// 使用枚举包含所有 path
enum Api {
  // 平台子用户单设备预警查询
  selectDevEarlyWarnConf = '/platFormSubUser/select/devEarlyWarnConf',

  // 平台子用户单设备开启预警
  openDevEarlyWarnConf = '/platFormSubUser/open/devEarlyWarnConf',

  // 平台子用户单设备关闭预警
  closeDevEarlyWarnConf = '/platFormSubUser/close/devEarlyWarnConf',

  // 平台子用户单设备修改预警数据
  editDevEarlyWarnConfData = '/platFormSubUser/edit/devEarlyWarnConfData',

  // 平台子用户修改预警配置
  editDevEarlyWarnConf = '/platFormSubUser/edit/devEarlyWarnConf',
}


/* 接口对接函数 ---------------------------------------------------------------- */
// 平台子用户单设备预警查询的Api
export const selectDevEarlyWarnConfApi = (data: { devId: number | string | null }) => {
  return Request.post(Api.selectDevEarlyWarnConf, qs.stringify(data))
}

// 平台子用户单设备开启预警的Api
export const openDevEarlyWarnConfApi = (data: { confId: number | string | null }) => {
  return Request.post(Api.openDevEarlyWarnConf, qs.stringify(data))
}

// 平台子用户单设备关闭预警的Api=
export const closeDevEarlyWarnConfApi = (data: { confId: number | string | null }) => {
  return Request.post(Api.closeDevEarlyWarnConf, qs.stringify(data))
}


// 平台子用户单设备修改预警数据的Api
export const editDevEarlyWarnConfDataApi = (data: Object) => {
  return axios({
    method: 'post',
    url: 'http://192.168.0.161:11006' + Api.editDevEarlyWarnConfData,
    data: data
  })
}


// 平台子用户修改预警配置的Api
export const editDevEarlyWarnConfApi = (data: { confId: number | string, startTime: string, endTime: string, intervalTime: string | number }) => {
  return Request.post(Api.editDevEarlyWarnConf, qs.stringify(data))
}